﻿//using Android.Graphics.Drawables;
//using Games.Common;
//using System.Linq;
//using Xamarin.Forms;
//using Xamarin.Forms.Platform.Android;

//[assembly: ExportRenderer(typeof(LineColorButton), typeof(Games.Droid.ControlRenders.LineColorButtonRender))]
//namespace Games.Droid.ControlRenders
//{
//    class LineColorButtonRender : NormalButtonRender
//    {
//        public LineColorButtonRender(Android.Content.Context context) : base(context)
//        {

//        }
//        protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
//        {
//            //this.Control.SetBackgroundResource(Resource.Drawable.gradient_button_style);
//            var stack = e.NewElement as LineColorButton;
//            if(stack == null)
//            {
//                base.OnElementChanged(e);
//                return;
//            }
//            if(stack.StartColor == stack.EndColor)
//            {
//                stack.BackgroundColor = stack.StartColor;
//                base.OnElementChanged(e);
//                return;
//            }
//            base.OnElementChanged(e);

//            GradientDrawable.Orientation orientation = stack.IsHorizontal
//                ? GradientDrawable.Orientation.LeftRight : GradientDrawable.Orientation.TopBottom;

//            var selector = new StateListDrawable();
//            var enanablecolors = WithMiddleColor(stack.StartColor, stack.EndColor, stack.MiddleRate);
//            var shapeEnabled = new GradientDrawable(orientation, enanablecolors);
//            shapeEnabled.SetCornerRadius(stack.CornerRadius);
//            selector.AddState(EnabledStateSet.ToArray(), shapeEnabled);

//            var disanablecolors = WithMiddleColor(Xamarin.Forms.Color.Gray, Xamarin.Forms.Color.Gainsboro, stack.MiddleRate);
//            var shapeDisabled = new GradientDrawable(orientation, disanablecolors);
//            shapeDisabled.SetCornerRadius(stack.CornerRadius);
//            selector.AddState(EmptyStateSet.ToArray(), shapeDisabled);

//            this.Control.SetBackground(selector);
//        }
//    }
//}